<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<input type="text" id="d1" placeholder="学生姓名">
<input type="text" id="d2" placeholder="班级">
<input type="text" id="d3" placeholder="学号">
<input type="button" value="添加" onclick="f()">
<table border="2">
  <caption>学生信息</caption>
  <tr>
    <th>姓名</th>
    <th>班级</th>
    <th>学号</th>
  </tr>

</table>

<script>
  let d1 = document.querySelector("#d1");
  let d2 = document.querySelector("#d2");
  let d3 = document.querySelector("#d3");
  function f() {
    //创建tr和td
    let tr = document.createElement("tr");
    let name = document.createElement("td");
    let bj = document.createElement("td");
    let xh = document.createElement("td");
    name.innerText=d1.value;
    bj.innerText = d2.value;
    xh.innerText =d3.value;

    //把td装入tr
    tr.append(name,bj,xh);
    let table = document.querySelector("table");
    table.append(tr)
  }
</script>

</body>
</html>